Skip to content

fix: handle OCPI version negotiation in push_object#21

Merged
alfonsosastre merged 3 commits intofeat/push-v2-3-0-supportfrom
fix/push-version-negotiation
Feb 24, 2026
Merged

fix: handle OCPI version negotiation in push_object#21
alfonsosastre merged 3 commits intofeat/push-v2-3-0-supportfrom
fix/push-version-negotiation

Conversation

@alfonsosastre
Copy link
Contributor

Summary

  • push_object now handles both versions URLs and version details URLs as endpoints_url
  • When the response is a versions list (data is a list), it automatically negotiates the best mutual version and fetches the details URL to discover endpoints
  • This follows the proper OCPI spec flow: GET /versions → pick version → GET /details → push

Context

Payter's versions endpoint is at /ocpi/ptp/versions which returns a list of versions. Previously push_object expected a version details URL directly, causing list indices must be integers or slices, not str errors.

Test plan

  • All 32 push-related tests pass
  • Deploy with elu-ocpi and verify push to Payter staging succeeds end-to-end

Made with Cursor

alfonsosastre and others added 3 commits February 24, 2026 09:29
* feat: add OCPI 2.3.0 support to push functionality

send_push_request now matches endpoints by RECEIVER role for 2.3.x
(same as 2.2.x), and push_object already base64-encodes tokens for
any version beyond 2.1.x. Previously 2.3.0 pushes would silently
use an empty base_url because the version check only covered "2.2".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: future-proof push endpoint version check

Replace explicit startswith("2.2") or startswith("2.3") with
a negated check, so any version beyond 2.0.x/2.1.x automatically
uses RECEIVER role filtering without needing code changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: apply ruff format to push.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Alfonso Sastre <alfonso@elumobility.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
push_object now accepts both a versions URL and a version details URL
as endpoints_url. When a versions list is returned (data is a list),
it automatically picks the best mutual version and fetches the details
URL to discover endpoints. This follows the proper OCPI spec flow:

1. GET /versions → list of supported versions with details URLs
2. Pick best mutual version
3. GET /{version}/details → list of endpoints
4. Push to the correct module endpoint

Co-authored-by: Cursor <cursoragent@cursor.com>
The endpoint URL from version details doesn't include a trailing
slash, causing the country_code to be concatenated directly
(e.g. locationsDE/ELU/... instead of locations/DE/ELU/...).

Co-authored-by: Cursor <cursoragent@cursor.com>
@alfonsosastre alfonsosastre merged commit 9ad51b2 into feat/push-v2-3-0-support Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant